xbiascom ( )
{
    ls bias*.fit >listbias
    if test -s listbias
    then
	echo "have bias images"
	rm -rf Zero.fit
	xbiascom.sh listbias
  fi
  if test -s Zero.fit 
  then
	echo "have Zero.fit "
	echo "bias successfull"
	xzerocorr
  fi
}

xzerocorr ( )
{

ls flat*r*.fit >listflat
if test -s listflat
then
	xzerocorr_list.sh listflat Zero.fit
	echo "have flat r image"
	xflatcom.sh listflat
	wait
	firstimg=`head -1 listflat`
	filter=`gethead $firstimg "FILTER"`
	outputimg=`echo "Flat_"$filter".fit"`

	if test -s $outputimg
	then
		echo "have $outputimg, finished"
	fi
fi
}

xbiascom
